<?php
/**
*
* @package ppkBB3cker
* @version $Id: posting_addfields_add1.php 1.000 2009-03-25 11:39:00 PPK $
* @copyright (c) 2009 PPK
* @license http://opensource.org/licenses/gpl-license.php GNU Public License
*
*/

/**
* @ignore
*/
if (!defined('IN_PHPBB'))
{
	exit;
}


$post_addfields='';
$subj_fields=array();
if($subj_fields)
{
	foreach($subj_fields as $sf)
	{
		if(request_var($sf, ''))
		{
			$_REQUEST['subject'].=' ['.$_REQUEST[$sf].']';
		}
	}
}
foreach($array_addfields as $k)
{
	$c=intval(@$user->lang['TRACKER_FORUM_ADDFIELDS_COUNT'][$k]);
	$cf_bbcodes=@$user->lang['TRACKER_FORUM_ADDFIELDS_BBCODES'][$k];
	if($c)
	{
		$tmp_addfields=array();
		for($i=1;$i<=$c;$i++)
		{
			if(@$_POST[$k.$i])
			{
				if($cf_bbcodes)
				{
					$tmp_addfields[]=sprintf($cf_bbcodes, $_POST[$k.$i]);
				}
				else
				{
					$tmp_addfields[]=$_POST[$k.$i];
				}
			}
		}
		if($tmp_addfields)
		{
			$br_addfields=@$user->lang['TRACKER_FORUM_ADDFIELDS_BR'][$k] ? $user->lang['TRACKER_FORUM_ADDFIELDS_BR'][$k] : '';
			$post_addfields ? $post_addfields.=$br_addfields."\r\n" : '';
			$cf_bbcode=@$user->lang['TRACKER_FORUM_ADDFIELDS_BBCODE'][$k];
			if($cf_bbcode)
			{
				$post_addfields.=sprintf($cf_bbcode, implode("\r\n", $tmp_addfields));
			}
			else
			{
				$post_addfields.=implode("\r\n", $tmp_addfields);
			}
		}
	}
	else
	{
		$v=@$_POST[$k];
		$tmp_addfields=array();
		$br_addfields=@$user->lang['TRACKER_FORUM_ADDFIELDS_BR'][$k] ? $user->lang['TRACKER_FORUM_ADDFIELDS_BR'][$k] : '';
		$post_addfields && $v ? $post_addfields.=$br_addfields."\r\n" : '';
		if($v)
		{
			$cf_bbcodes=@$user->lang['TRACKER_FORUM_ADDFIELDS_BBCODES'][$k];
			if($cf_bbcodes)
			{
				$tmp_addfields[]=sprintf($cf_bbcodes, $v);
			}
			else if(@$user->lang['TRACKER_FORUM_ADDFIELDS'][$k])
			{
				$tmp_addfields[]="[b]{$user->lang['TRACKER_FORUM_ADDFIELDS'][$k]}[/b]: $v";
			}
			$cf_bbcode=@$user->lang['TRACKER_FORUM_ADDFIELDS_BBCODE'][$k];
			if($tmp_addfields)
			{
				if($cf_bbcode)
				{
					$post_addfields.=sprintf($cf_bbcode, implode("\r\n", $tmp_addfields));
				}
				else
				{
					$post_addfields.=implode("\r\n", $tmp_addfields);
				}
			}
		}
	}

}
$post_addfields ? $_REQUEST['message']=$post_addfields."\r\n".$_REQUEST['message'] : '';

?>
